package b.h.z;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("UserService")
public class UserService {
	
	@GET
	@Path("/jsonuser/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public User getJsonUser(@PathParam("id") String id) {
		User user = new User();
		user.setId(1);
		user.setName("xxoo");
		user.setAge(29);
		user.setSex(1);
		return user;
	}
	
	@GET
	@Path("/xmluser/{id}")
	@Produces(MediaType.APPLICATION_XML)
	public User getXmlUser(@PathParam("id") String id) {
		User user = new User();
		user.setId(1);
		user.setName("xxoo");
		user.setAge(29);
		user.setSex(1);
		return user;
	}
	
	@GET
	@Path("/textuser/{id}")
	@Produces(MediaType.TEXT_XML)
	public String getTextUser(@PathParam("id") String id) {
		User user = new User();
		user.setId(1);
		user.setName("xxoo");
		user.setAge(29);
		user.setSex(1);
		return user.toString();
	}
	
	
	@POST
	@Path("/user/{user}")
	@Consumes(MediaType.APPLICATION_XML)
	@Produces(MediaType.APPLICATION_XML)
	public User addUser(@PathParam("user") User user) {
		return user;
	}
}
